<?php
if (!defined('IN_MEDIA')) die("Hacking attempt");
function cut_str($str_cut,$str_c,$val)
{	
	$url=split($str_cut,$str_c);
	$urlv=$url[$val];
	return $urlv;
}

function encode($str){
	$t = gmdate("i", time()+7*3600);
	$t=($t+1234560);
	$t=$str.'_'.$t;
	$t= str_replace(array('9','8','7','6','5','4','3','2','1','0','_'),array('a','b','c','d','e','g','h','k','v','u','w'),$t);
	return $t;
}
function get_link_total($url,$type) {
	global $web_link;
	$link=$url;
	$mylink='http://phimanhdao.com/player/mediaplayer.swf?file=';
	$t="";
	if (preg_match("#thienduongviet.org/getlink/(.*?)#", $url)){
			$link=str_replace('http://phimanhdao.com/player/mediaplayer.swf?file=',$mylink,$url);
			$url=$link;
		}
	
   
	if (preg_match('#veoh.com\/videodetails2\.swf\?permalinkId=(.*?)#s', $url) || preg_match('#veoh.com\/veohplayer\.swf\?permalinkId=(.*?)#s', $url)){
		$id = cut_str('watch/',$url,1);
		$link2=$id;
		$url=$link2;
    }
    elseif (preg_match("#video.google.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#ooyala.com/online/(.*?)#s",$url)) {
		$id = cut_str('online/',$url,1);
		$link2=$id;
		$url=$link2;
	}
	elseif (preg_match("#go.vn/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#modovideo.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#movreel.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#openfile.ru/video/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#divxstage.eu/video/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#uploads.glumbo.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#sharefiles4u.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#banbe.net/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#xvidstage.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#hulkshare.com/(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
    elseif (preg_match('#veoh.com/(.*?)#s', $url, $id_sr)){
		$id = cut_str('watch/',$url,1);
		$link2=$id;
		$url=$link2;
    }
    else if (preg_match('#picasaweb.google.com/lh/photo/(.*?)#s', $url, $id_sr)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match('#mp3.zing.vn/tv/media/(.*?)#s', $url, $id_sr)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match('#2shared.com/file/(.*?)#s', $url, $id_sr)){
		$id = cut_str('file/',$url,1);
		$link2=$id;
		$url=$link2;
	}
	else if (preg_match('#2shared.com/video/(.*?)#s', $url, $id_sr)){
		$id = cut_str('video/',$url,1);
		$link2=$id;
		$url=$link2;
	}
	else if (preg_match('#4shared.com/file/(.*?)#s', $url, $id_sr)){
		$id = cut_str('file/',$url,1);
		$link2=$id;
		$url=$link2;
	}
		else if (preg_match('#4shared.com/video/(.*?)#s', $url, $id_sr)){
		$id = cut_str('video/',$url,1);
		$link2=$id;
		$url=$link2;
	}
		else if (preg_match('#4shared.com/embed/(.*?)#s', $url, $id_sr)){
		$id = cut_str('embed/',$url,1);
		$link2=$id;
		$url=$link2;
	}
	elseif (preg_match("#videoweed.es/file/([^/]+)#",$url,$id_sr)) {
		$id = cut_str('file/',$url,1);
		$link2='http://embed.videoweed.es/embed.php?v='.$id;
		$url=$link2;
	}
	elseif (preg_match("#videobb.com/video/([^/]+)#",$url,$id_sr)) {
		$id = cut_str('video/',$url,1);
		$link2='http://videobb.com/e/'.$id;
		$url=$link2;
	}
	elseif (preg_match("#videobb.com/e/([^/]+)#",$url,$id_sr)) {
		$id = cut_str('e/',$url,1);
		$link2='http://videobb.com/e/'.$id;
		$url=$link2;
	}
		else if (preg_match('#share.vnn.vn/dl.php/(.*?)#s', $url, $id_sr)){
		$id = $url;
		$url=$id;
	}
    else if (preg_match("#videozer.com/embed/(.*?)#s", $url, $id_sr)){
		$id = cut_str('embed/',$url,1);
		$link2='http://videozer.com/flash/'.$id;
		$url=$link2;
    }
    else if (preg_match('#videozer.com/video/(.*?)#s', $url, $id_sr)){
		$id = cut_str('video/',$url,1);
		$link2='http://videozer.com/flash/'.$id;
		$url=$link2;
    }
	elseif (preg_match('#clip.vn/watch/(.*?)#s',$url)) {
		$id = cut_str('/',$url,4);
		$link2 = 'http://clip.vn/watch/'.$id;
		$url=$link2;
	}
	elseif (preg_match('#clip.vn/w/(.*?)#s',$url)) {
		$id = cut_str('/',$url,4);
		$link2 = 'http://clip.vn/watch/'.$id;
		$url=$link2;
	}
    elseif (preg_match("#dailymotion.com/video/(.*?)#s",$url,$id_sr)) {
		$id = cut_str('/',$url,4);		
		$link2='http://www.dailymotion.com/swf/'.$id;
		$url=$link2;
	}
   else if (preg_match("#youtube.com/watch\?v=(.*?)#s", $url,$id_sr)){
		$id=cut_str('=',$url,1);
		$link2='http://www.youtube.com/v/'.$id;
		$url=$link2;
	}

	elseif (preg_match("#youtube.com/v/([^/]+)#",$url,$id_sr)) {

		$id = cut_str('v/',$url,1);
		$link2='http://www.youtube.com/v/'.$id;
		$url=$link2;

		

    }

	elseif (preg_match("#youtube.com/feeds/api/playlists/([^/]+)#",$url,$id_sr)) {
		$id = cut_str('playlists/',$url,1);
		$link2='http://gdata.youtube.com/feeds/api/playlists/'.$id;
		$url=$link2;
    }
	elseif (preg_match("#viddler.com/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#video.zing.vn/([^/]+)#",$url,$id_sr)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#video.zing.vn/video/clip/([^/]+)#",$url,$id_sr)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#mp3.zing.vn/([^/]+)#",$url,$id_sr)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#video.timnhanh.com/xem-clip/([^/]+)#",$url,$id_sr)) {
		$id = $id_sr[1];
		$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/vtimnhanh/'.$id.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link;
	}
	else if (preg_match("#video.yume.vn/xem-clip/([^/]+)#",$url,$id_sr)) {
		$id = $id_sr[1];
		$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/vtimnhanh/'.$id.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link;
		
		}
		else if (preg_match("#video.yume.vn/video-clip/([^/]+)#",$url,$id_sr)) {
		$id = $id_sr[1];
		$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/vtimnhanh/'.$id.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link;
		
		}
	else if (preg_match("#phimf.com/f/(.*?)#s", $url)){
		$link=str_replace('http://phimf.com/f/','http://phimanhdao.com/phim/player/mediaplayer.swf?file=/phimf/',$url);
		$url=$link.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$url;
		
	}
	else if (preg_match("#badongo.com/vid/(.*?)#s", $url,$id_sr)){
		$id=cut_str('/',$url,4);
		$link2='http://www.badongo.com/vid/'.$id.'';
		$url=$link2;
		
	}
	else if (preg_match("#megavideo.com/\?v=(.*?)#s", $url,$id_sr)){
		$id=cut_str('=',$url,1);
		$link=$mylink.'/megavideo/'.$id.'.flv';
		$url='http://wwwstatic.megavideo.com/mv_player.swf?v='.$id;
	}
	else if (preg_match("#metacafe.com/watch/(.*?)#s", $url)){
		$id = cut_str('/',$url,4);
		$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/metacafe/'.$id.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link.'&autostart=true';
	}
	else if (preg_match("#timvui.vn/video/(.*?)#s", $url)){
		$id = cut_str('view/',$url,1);
		$id = cut_str('\.',$id,0);
		$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/timvui/'.$id.'.flv';
		$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link;
	}
	else if (preg_match("#nhaccuatui.com(.*?)#s", $url)){
			$kind=substr($url,31,1);
			$id = cut_str('=',$url,1);
			$link=$mylink.'/nct/'.$id.'.flv';
			if($kind=="M")
				$url='http://www.nhaccuatui.com/m/'.$id;
			else if($kind=="L")
				$url='http://www.nhaccuatui.com/L/'.$id;
			//$url=$web_link.'/'.'player.swf?file='.$link.'&plugins=http://static.hosting.vcmedia.vn/players/plugins/sharePlugin.swf&plugin.chia_se_link='.$link_seo;
			
	}
	else if (preg_match("#video.baamboo.com(.*?)#s", $url)){
			$t = cut_str('/',$url,4);
			$id =cut_str('/',$url,6);
			$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/baamboo/'.$id.'_'.$t.'.flv';
			$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link.'&autostart=true';
	}
	else if (preg_match("#video.baamboo.com(.*?)#s", $url)){
			$t = cut_str('/',$url,4);
			$id =cut_str('/',$url,6);
			$link='http://phimanhdao.com/phim/player/mediaplayer.swf?file=/baamboo/'.$id.'_'.$t.'.flv';
			$url='http://phimanhdao.com/phim/player/mediaplayer.swf?file='.$link.'&autostart=true';
	}
	else if (preg_match("#sendspace.com/file/(.*?)#s", $url)){
		$id = cut_str('/',$link,4);
		$link2='http://www.sendspace.com/file/'.$id;
		$url=$link2;
	}
	else if (preg_match("#vidxden.com/(.*?)#s", $url)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#movshare.net/video/(.*?)#s", $url)){
		$id = cut_str('/',$link,4);
		$link2='http://www.movshare.net/video/'.$id;
		$url=$link2;
	}
	elseif (preg_match("#twitvid.com/(.*?)#s",$url)) {
		$id = cut_str('/',$url,3);		
		$link2='http://www.twitvid.com/embed.php?guid='.$id;
		$url=$link2;
	}
	elseif (preg_match("#ovfile.com/(.*?)#s",$url)) {
		$id = cut_str('/',$url,3);		
		$link2='http://ovfile.com/'.$id;
		$url=$link2;
	}
	else if (preg_match("#novamov.com/video/(.*?)#s", $url)){
		$id = cut_str('/',$link,4);
		$link2='http://www.novamov.com/video/'.$id;
		$url=$link2;
	}
	elseif (preg_match("#zippyshare.com/v/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#cyworld.vn/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#megafun.vn/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#[0-9]/[0-9]+(.*?)#s",$url)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#speedyshare.com/files/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#mediafire.com/?(.*?)#s", $url)){
		$id = $url;
		$url=$id;
	}
	else if (preg_match("#video.tamtay.vn/(.*?)#s", $url)){
		$id = cut_str('/',$link,4);
		$link2='http://video.tamtay.vn/play/'.$id;
		$url=$link2;
	}
	elseif (preg_match("#video.rutube.ru/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#video.seeon.tv/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#zalaa.com/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#vidbux.com/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#eyvx.com/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
	elseif (preg_match("#film.rolo.vn/([^/]+)#",$url,$id_sr)) {
		$id = $url;
		$url=$id;
	}
		
	if (($t=="") && (substr_count($url,$web_link.'/player/mediaplayer.swf') != 0)) 
		//$url=$url.'&plugins=captions-1&captions.file='.$web_link.'/'.'captions.xml&captions.back=ffff&logo='.$web_link.'/logo.png';
		$url=$url.'&logo='.$web_link.'/logo.png';
	if ($type==0) $trave=$url;
	elseif ($type==1) $trave=$link;
return $trave;
}
?>